home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Frameworks / MacZoop 1.6.5 / Basic Classes / Z Headers / ZWindow.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-21  |  5.2 KB  |  178 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************************
  2. *
  3. *
  4. *            ObjectMacZapp        -- a standard Mac OOP application template
  5. *
  6. *
  7. *
  8. *            ZWindow.h        -- the window object
  9. *
  10. *
  11. *
  12. *
  13. *
  14. *            © 1996, Graham Cox
  15. *
  16. *
  17. *
  18. *
  19. *************************************************************************************************/
  20.  
  21. #pragma once
  22.  
  23. #ifndef __ZWINDOW__
  24. #define    __ZWINDOW__
  25.  
  26. #ifndef __ZCOMMANDER__
  27. #include    "ZCommander.h"
  28. #endif
  29.  
  30. class    ZUndoTask;
  31.  
  32. class    ZWindow : public ZCommander
  33. {
  34. protected:
  35.     Rect        sizeRect;            // min and max sizes for window
  36.     WindowPtr    macWindow;            // the mac window associated with this object
  37.     short        windID;                // res ID of 'WIND' template
  38.     Boolean        dirty;                // TRUE if window needs to be saved
  39.     Boolean        isNamed;            // TRUE if window has a name other than "untitled"
  40.     FSSpec        macFile;            // the file that corresponds to this window
  41.     OSType        macFType;            // file type last opened
  42.     Boolean        printable;            // TRUE if this window can be printed (default FALSE)
  43.     Boolean        isPrinting;            // TRUE if draw operation is to printer
  44.     Boolean        floating;            // TRUE if this is a floating window
  45.     Boolean        disableAutoClose;    // if TRUE, this window is skipped during Quit or Close All
  46.     
  47. public:
  48.     ZWindow( ZCommander* aBoss, const short windowID );
  49.     virtual ~ZWindow();
  50.  
  51. // initialisation (MUST be called after construction)    
  52.     virtual void    InitZWindow();
  53.     
  54. // drawing and clicking
  55.     virtual void    Focus();
  56.     virtual void    Draw();
  57.     virtual void    DrawGrow();
  58.     virtual void    DrawContent();
  59.     virtual void    Click( const Point mouse, const short modifiers);
  60.     virtual void    AdjustCursor( const Point mouse, const short modifiers);
  61.     virtual void    PostRefresh();
  62.     virtual Boolean    ClickInSamePlace( const Point click1, const Point click2 );
  63.     
  64. // window state manipulation
  65.     virtual void    Hide();
  66.     virtual void    Show();
  67.     virtual void    Select();
  68.     virtual void    Activate();
  69.     virtual void    Deactivate();
  70.     virtual Boolean    Close( const short phase );
  71.     virtual Boolean    CloseSubsidiaryWindows( const short phase );
  72.     
  73. // command handling
  74.     virtual void    HandleCommand( const long aCmd );
  75.     virtual void    HandleCommand( const short menuID, const short itemID );
  76.     virtual void    UpdateMenus();
  77.     virtual void    SetTask( ZUndoTask* aTask );
  78.     
  79. // sizing and zooming    
  80.     virtual void    SetSizeRect( const Rect& szRect );
  81.     virtual void    GetSizeRect( Rect* szRect );
  82.     virtual void    Zoom( const short partCode );
  83.     virtual void    PlaceAt( const short hGlobal, const short vGlobal );
  84.     virtual void    SetSize( const short width, const short height, const Boolean reDraw );
  85.     virtual void    SetSize( const short width, const short height ) { SetSize(width, height, TRUE); };
  86.     virtual void    SetStdZoomRect( const Rect& aRect );
  87.     
  88. // file handling
  89.     virtual Boolean    Save( const Boolean forceSaveAs = FALSE );
  90.     virtual void    SaveFile();
  91.     virtual void    Revert();
  92.     virtual void    SetFile( const FSSpec& aFile );
  93.     virtual void    OpenFile( const OSType aFileType );
  94.     virtual void    PickFile( StandardFileReply* macReply );
  95.     
  96. // print handling
  97.     virtual void    CalcPages( const Rect& paperRect, short* pagesH, short* pagesV );
  98.     virtual void    PrintOnePage( const short pageNum, const Rect& paperRect );
  99.     virtual void    PrintingStarting() { isPrinting = TRUE; };
  100.     virtual void    PrintingFinishing() { isPrinting = FALSE; };
  101.     
  102.     inline    Boolean    IsPrintable() { return printable; };
  103.     
  104. // other info
  105.     virtual void    SetTitle( Str255 aTitle );
  106.     virtual void    GetName( Str255 name );
  107.     virtual void    GetContentRect( Rect* contents );
  108.     virtual void    GetBounds( Rect* aBounds ) { GetContentRect( aBounds ); };
  109.     virtual Boolean    IsVisible();
  110.  
  111. // positioning and frame info:    
  112.     virtual short    GetTitleBarHeight();
  113.     virtual void    GetStructureRegion( RgnHandle aRgn );
  114.     virtual void    GetContentRegion( RgnHandle aRgn );
  115.     virtual void    GetStructureFrameBorder( Rect* aRect );
  116.     virtual void    GetGlobalPosition( short* hGlobal, short* vGlobal );
  117.  
  118.     virtual ZCommander*    GetHandler();
  119.     
  120.     inline     WindowPtr    GetMacWindow(){ return macWindow; };
  121.     inline    Boolean        Floats() { return floating; };
  122.     inline    Boolean        NoAutoClose() { return disableAutoClose; };
  123.     inline    void        GetFileSpec( FSSpec* aSpec ) { *aSpec = macFile; };
  124.     inline  Boolean        IsDirty() { return dirty; };
  125.     inline    void        SetDirty( Boolean dState ) { dirty = dState; };
  126.     
  127. protected:
  128.  
  129.     virtual void    MakeMacWindow( const short windID );
  130.  
  131. };
  132.  
  133.  
  134.  
  135. #define            kNoFile                    -9999
  136. #define            kRevertConfirmAlertID    135
  137.  
  138.  
  139. /*
  140.  
  141.      ZWindows manage Mac windows. The refCon of a macWindow in Object MacZapp is the object
  142.     reference. This class handles all types of non-dialog windows. For dialogs, use ZDialog,
  143.     which is a subclass of this. A ZWindow is really equivalent to a document, since it has
  144.     methods for reading and writing its contents to files. However, you can ignore this
  145.     facility for non-document windows. This approach simplifies the framework, since you don't
  146.     need separate classes for different types of windows.
  147.     
  148. */
  149.  
  150.  
  151. #define        kInfinityWindoidDefinition    128
  152.  
  153. // structure of "WIND' resource- we take a peek here ourselves to determine if the
  154. // window is a floater or not
  155.  
  156. #if PRAGMA_ALIGN_SUPPORTED
  157. #pragma options align=mac68k
  158. #endif
  159.  
  160.  
  161. typedef struct
  162. {
  163.     Rect        bounds;
  164.     short        procID;
  165.     short        filler;
  166.     Boolean        visible;
  167.     Boolean        goAway;
  168.     long        refCon;
  169.     Str255        title;
  170. }
  171. WindTemplate, *WindTemplatePtr, **WindTemplateHdl;
  172.  
  173.  
  174. #if PRAGMA_ALIGN_SUPPORTED
  175. #pragma options align=reset
  176. #endif
  177.  
  178. #endif